package com.example.demo.repository;

import com.example.demo.model.Major;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;

@Repository
public interface MajorRepository extends JpaRepository<Major, Long> {
    Optional<Major> findByCodeAndCollegeId(String code, Long collegeId);
    List<Major> findByNameContaining(String name);
    List<Major> findByCollegeId(Long collegeId);
    Page<Major> findByStatus(Major.Status status, Pageable pageable);
    Page<Major> findByNameContaining(String name, Pageable pageable);
    
    // 添加按名称和学院ID查找的方法（用于导入功能）
    Optional<Major> findByNameAndCollegeId(String name, Long collegeId);
}